<?php
    session_start();
    include 'bd.php';
    
    if((!isset($_GET["login"]))OR($_GET["login"])==''){
        $_SESSION["error"] = "Вы не ввели логин";
        header("location: index.php");
        exit();
    }
    else {$login = $_GET["login"];}
    
    
    if((!isset($_GET["pass"]))OR($_GET["pass"])==''){
        $_SESSION["error"] = "Вы не ввели пароль";
        header("location: index.php");
        exit();
    }
    else {$pass = $_GET["pass"];}
    $result = mysql_query("SELECT * FROM users WHERE login='$login'");
    $myrow = mysql_fetch_array($result);
    if ((!isset($myrow["login"]))OR ($myrow["login"] == "")) {
        $_SESSION["error"] = "Данного пользователя не существует";
        header("location: index.php");
        exit();
    } 
    if ($myrow["pass"] != $pass) {
        $_SESSION["error"] = "Пароль не верный";
        header("location: index.php");
        exit();
    }
    
    $_SESSION["login"] = true;
    
    header ("location: main.php");
?>


